#include<bits/stdc++.h>
//#define int long long
#define endl '\n'
using namespace std;
const int mod=998244353,inf=0x3f3f3f3f3f3f3f3f;
const int N=5e4+10,M=1e3+10;
mt19937 rnd(time(0));
int f[N][M],n,m;
string s,t;
int fail[N],ch[N][26]; 
void getmax(int &x,int y){x=max(x,y);}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("neck.in","r",stdin);
	freopen("neck.out","w",stdout);
	cin >> s >> t;
	n=s.size(),m=t.size();
	s=" "+s,t=" "+t;
	for ( int i = 2 ; i <= m ; i++ )
	{
		fail[i]=fail[i-1];
		while(fail[i]&&t[fail[i]+1]!=t[i])fail[i]=fail[fail[i]];
		if(t[fail[i]+1]==t[i])fail[i]++;
	}
	for ( int i = 1 ; i <= m ; i++ )
	{
		ch[i-1][t[i]-'a']=i;
		for ( int j = 0 ; j < 26 ; j++ )
			if(j+'a'!=t[i])ch[i-1][j]=ch[fail[i-1]][j];
	}
	for ( int i = 1 ; i <= n ; i++ )
	{
		for ( int j = 0 ; j < m ; j++ )
			getmax(f[i+1][j],f[i][j]),
			getmax(f[i+1][ch[j][s[i]-'a']],f[i][j]+1);
	}
	int ans=0;
	for ( int j = 0 ; j < m ; j++ )
		getmax(ans,f[n+1][j]);
	cout << ans;
	return 0;
}
/*
nezhaheaobing
aobing
*/

